


class   ListNode{
    int val;
    ListNode next;

    public   ListNode(int val){
        this.val=val;
    }

}

public class Main {

    public ListNode remove(ListNode  head,int N){
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode listNode = removeT(head, N + 1);
        listNode.next=listNode.next.next;
        return dummy.next;
    }


    public ListNode  removeT(ListNode  head,int N){
        int i=0;
        ListNode fast=head;
        while (i<N){
            fast=fast.next;
            i++;
        }
        ListNode slow=head;
        while (fast!=null){
            fast=fast.next;
            slow=slow.next;
        }
        return  slow;
    }





}
